package components.plugins.album
{
	import SEApp.components.se_source;
	
	import UIFree.uif_component;
	
	import components.clt_arrowB;
	import components.clt_box;
	import components.clt_component;
	import components.game.clt_gamePart;
	import components.tools.clt_selectLayer;
	
	import data.clt_data;
	
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	import mx.utils.object_proxy;
	
	public class clt_albumLayer extends clt_component {
		private var _collagesLayer	: clt_gamePart;
		private var _view			: se_source;
		
		public function clt_albumLayer(parent:uif_component) {
			var rect: Rectangle = parent.getInner();
			super(parent, rect.x, rect.y, rect.width, rect.height);
		}
		
		override protected function listenEvents():void {
			super.listenEvents();
			addEvent(clt_albumItem.RELEASEITEM, doReleaseItem);
		}
		
		override protected function createComponents():void {
			var rect: Rectangle = getInner();
			rect.left += rect.width - 150;
			rect.height = clt_arrowB.DEFAULTHEIGHT;
			addButton('Закрыть', function(e: Event): void {
				dispatchEvent(new Event(Event.CLOSE));
			}, rect);
			
			rect = getInner();
			rect.top += clt_arrowB.DEFAULTHEIGHT;
			rect.height = 120;
			_collagesLayer = new clt_gamePart(this, rect.x, rect.y, rect.width, rect.height, 'Мои коллажи', clt_albumItem);
			_collagesLayer.itemsLayer.addEvent(Event.SELECT, doReleaseItem);
			
			rect.y += rect.height;
			rect.height = 620;
			_view	= new se_source(this, rect.x, rect.y, rect.width, rect.height);
		}
		
		public function assignList(a_list: Array): void {
			_collagesLayer.assignList(a_list);
		}
		
		private function doReleaseItem(e: Event): void {
			var item: Object = _collagesLayer.itemsLayer.selectItem.object;
			
			_view.loadSource(clt_servers.ALBUM_URL + item.collage_id + clt_data.JPGEXT);
		}
	}
}